{template 'common/header'}
<ul class="nav nav-tabs">
    <li {if $op == 'manage'} class="active"{/if}><a href="{php echo $this->createWebUrl('bbs', array('op' => 'manage'))}">所有帖子</a></li>
    <!--<li {if $op== 'check'} class="active"{/if}><a href="{php echo $this->createWebUrl('bbs', array('op' => 'check'))}">待审核帖子</a></li>-->
</ul>
{if $op == 'manage'}

<div class="main">
    <form action="" method="post" class="form-horizontal form" id="form">
        <div class="panel panel-default">
            <div class="panel-heading">所有帖子</div>
            <div class="panel-body">
                <div class="table-responsive panel-body">

                    <table class="table table-hover" style="min-width: 300px;">
                        <thead class="navbar-inner">
                        <tr>
                            <th style="width:40px;">ID</th>
                            <th style="width:160px;">标题</th>
                            <th style="width:100px;">姓名</th>
                            <th style="width:100px;">手机</th>
                            <th style="width:250px;">帖子内容</th>
                            <th style="width:80px;">帖子时间</th>
                            <th style="width:80px;">管理</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $datalist $key $item}
                        <tr>
                            <td class="text-left">{php echo ++$key;}</td>
                            <td>{$item['title']}</td>
                            <td>{$item['truename']}</td>
                            <td>{$item['mobile']}</td>
                            <td>{$item['content']}</td>
                            <td>{php echo date('Y-m-d H:i',$item['createtime'])}</td>
                            <td><!--删除可以用ajax实现-->
                                <button type="button"  class="btn  btn-danger" onclick="if(confirm('是否删除?')){shanchu('manage','{$item['id']}')}else{return false;}">删除</button>
                            </td>
                        </tr>
                        {/loop}
                        {if !empty($datalist)}
                        <tr>
                            <td colspan="6">
                                <input type="hidden" name="token" value="{$_W['token']}" />
                            </td>
                        </tr>
                        {else}
                        <tr>
                            <td colspan="4">
                                没有数据
                            </td>
                        </tr>
                        {/if}
                        </tbody>
                    </table>
                </div>

            </div>
        </div>
    </form>
</div>
{$page}
{/if}
<script type="text/javascript">
    function shanchu(get,getid){
        if(get=='check'){
            var url = '{php echo $this->createWebUrl('list',array('op'=>'check'))}';
        }else{
            var url = '{php echo $this->createWebUrl('list',array('op'=>'manage'))}';
        }
        $.ajax({
            type:"POST",
            url:"{php echo $this->createWebUrl('deleteajax')}",
            data:{id:getid,ku:'wwr_book'},
            dataType:'json',
            cache:false,
            success:function(data){
                console.log(data.status);
                if(data.status=='1'){
                    alert("删除成功");
                    location.reload();
                }else{
                    alert("删除失败");
                }
            }
        });
    }
</script>
{template 'common/footer'}